package com.daidai.spinner

import game.engine.base.Node
import game.engine.base.show_scene_graph
import org.junit.Assert
import org.junit.Test

class TestNode {


    @Test
    fun test_add(){
        val root = Node()

        // 创建4个
        for (i in 1..4){
            val n = Node()
            for(j in 1..4){
                n.addChild(Node())
            }
            root.addChild(n)
        }
        Assert.assertEquals(4,root.children?.size)
    }

    @Test
    fun test_remove(){
        val root = Node()
        // 创建4个
        for (i in 1..4){
            val n = Node()
            for(j in 1..4){
                n.addChild(Node())
            }
            root.addChild(n)
        }

        root.children!![1].willDestroy = true

        //
        println(root.show_scene_graph())
        root.removeDiedChildren()
        println("====================")
        println(root.show_scene_graph())
    }


    @Test
    fun test_sort(){
        val root = Node()
        // 创建4个
        for (i in 1..4){
            val n = Node()
            for(j in 1..4){
                n.addChild(Node())
            }
            root.addChild(n)
        }

        println("====================")
        root.children!![1].zorder = 3
        root.children!![2].zorder = 2
        println(root.show_scene_graph())
        //root.draw(xxx)
        println(root.show_scene_graph())
    }


    @Test
    fun test_arr(){
        val arr = intArrayOf(0,1,2,3,4,5,6,7)
        for (i in arr.indices step 2){
            println(i)
        }
    }

}